package cn.njxzc.examples;

import java.util.Date;

public class Exam7_1 extends Thread {
	int sleepTime;
	String name;
	int counter;

	public Exam7_1(int x, String n) {
		sleepTime = x;
		name = n;
		counter = 0;
	}

	public void run() {
		while (counter < 10) {
			try {
				counter++;
				System.out.println(name + ":"
						+ new Date(System.currentTimeMillis()));
				Thread.sleep(sleepTime);
			} catch (InterruptedException e) {
				System.out.println(e);
			}
		}
	}

	public static void main(String[] args) {

		Exam7_1 tp1 = new Exam7_1(1000, "Fast Thread");

		tp1.start();

		Exam7_1 tp2 = new Exam7_1(3000, "Slow Thread");

		tp2.start();

	}

}
